from nltk.book import *

print('第一本书的标题', text1)
print('搜索文本')
print(text1.concordance("former"))
print('搜索相关词')
print(text1.similar('ship'))
print('查看词的出现位置')
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
print('text1 总字数', len(text1))
print('text1 的词集合')
text1_set = set(text1)
print('text1 总词数', len(text1_set))
print('is 词在 text4 中出现的次数', text4.count('is'))
print('统计词频并输出图像')
fdist1 = FreqDist(text1)
fdist1.plot(50, cumulative=True)
print('只出现一次的词')
print(fdist1.hapaxes())
print('体验完成')